//
//  SimpleLabel.m
//  BestTeam
//
//  Created by bigger on 2019/1/4.
//  Copyright © 2019年 BiggerFitness. All rights reserved.
//

#import "SimpleLabel.h"

@implementation SimpleLabel

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithText:(NSString *)text TextColor:(UIColor *)textColor TextFont:(UIFont *)font TextAlignment:(NSTextAlignment)alignment
{
    self = [super init];
    if (self) {
        self.textColor = textColor;
        self.text = text;
        self.font = font;
        self.textAlignment = alignment;
    }
    return self;
}


+ (instancetype)initWithText:(NSString *)text TextColor:(UIColor *)textColor TextFont:(UIFont *)font TextAlignment:(NSTextAlignment)alignment
{
    SimpleLabel *label = [[SimpleLabel alloc] initWithText:text TextColor:textColor TextFont:font TextAlignment:alignment];
    return label;
}


- (void)setShowMultipleTextWithLabel:(SimpleLabel *)label ShowText:(NSString *)showText TextColor:(UIColor *)textColor TextFont:(UIFont *)textFont FontRange:(NSRange)fontRange ColorRange:(NSRange)colorRange
{
    NSMutableAttributedString *multipleStr = [[NSMutableAttributedString alloc] initWithString:showText];
    if (textColor) {
        [multipleStr addAttribute:NSForegroundColorAttributeName  value:textColor range:colorRange];
    }
    if (textFont) {
        [multipleStr addAttribute:NSFontAttributeName  value:textFont range:fontRange];
    }
    
    label.attributedText = multipleStr;
}

@end
